﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PersonaLibrary.Data;

namespace PersonaLibrary.Commands.EditCommands
{
    public class DeleteOrganization : CommandBase
    {
        public override bool CanExecute(object parameter)
        {
            return parameter is int;
        }

        public override void Execute(object parameter)
        {
            using (LinqToDbDataContext context = new LinqToDbDataContext())
            {
                context.Organizations.DeleteOnSubmit(context.Organizations.Single(x => ((Organization)x).Id == (int)parameter));
                context.SubmitChanges();
            }
        }
    }
}
